//
//  PreDoctorCell.m
//  International_Hospital
//
//  Created by 统杰李 on 16/7/7.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "PreDoctorCell.h"

@interface PreDoctorCell ()

@property (nonatomic,strong) UILabel *doctorNameLabel;

@property (nonatomic,strong) UILabel *archiaterLabel;

@property (nonatomic,strong) UILabel *hospitalNameLabel;

@property (nonatomic,strong) UIButton *talkButton;

@end

@implementation PreDoctorCell

#pragma mark
#pragma mark - 重写model
- (void)setModel:(DoctorApplyModel *)model{
    
    _model = model;
    
    self.doctorNameLabel.text = model.doctor_name;
    self.archiaterLabel.text = @"主任医师";
    self.hospitalNameLabel.text = model.doctor_hospital_name;
    
}

#pragma mark
#pragma mark - 重写initWithStyle方法
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

#pragma mark
#pragma mark - 设置UI界面
-(void)setupUI{
    //给控件赋值
    self.doctorNameLabel = [self addChildLabel];
    self.archiaterLabel = [self addChildLabel];
    self.hospitalNameLabel = [self addChildLabel];
    
    self.doctorNameLabel.textColor = [UIColor blackColor];
    self.doctorNameLabel.font = [UIFont systemFontOfSize:17];
    
    //添加控件
    [self.contentView addSubview:self.doctorNameLabel];
    [self.contentView addSubview:self.archiaterLabel];
    [self.contentView addSubview:self.hospitalNameLabel];
    [self.contentView addSubview:self.talkButton];
    
    //添加约束
    [self.doctorNameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.left).offset(10);
        
        make.top.equalTo(self.contentView.top).offset(15);
        
    }];
    
    [self.archiaterLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.doctorNameLabel.right).offset(20);
        make.top.equalTo(self.doctorNameLabel.top);
    }];
    
    [self.hospitalNameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.doctorNameLabel.left);
        make.bottom.equalTo(self.contentView.bottom).offset(-20);
    }];
    
    [self.talkButton makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.right).offset(-15);
        make.centerY.equalTo(self.contentView.centerY);
        make.width.equalTo(80);
        make.height.equalTo(38);
        
    }];
}


#pragma mark -
#pragma mark 创建label的方法
-(UILabel *)addChildLabel{
    UILabel *labelNameString = [[UILabel alloc] init];
    
    labelNameString.textColor = [UIColor lightGrayColor];
    
    labelNameString.font = [UIFont systemFontOfSize:14];
    
    [labelNameString sizeToFit];
    
    return labelNameString;
    
}

#pragma mark
#pragma mark - 递交反馈button
-(UIButton *)talkButton{
    if (_talkButton == nil) {
        
        _talkButton = [[UIButton alloc] init];
       
        [_talkButton setBackgroundColor:[UIColor colorWithRed:34/255.0 green:183/255.0 blue:198.0/255 alpha:1]];
        
        [_talkButton setTitle:@"递交反馈" forState:UIControlStateNormal];
        [_talkButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        _talkButton.layer.cornerRadius = 7.0;
        
    }
    return  _talkButton;
}

@end
